package easy;

import java.util.HashMap;
import java.util.Map;

public class a面试题0102_判定是否互为字符重排 {
    public boolean CheckPermutation(String s1, String s2) {
        if (s1.length()!=s2.length()) return false;
        Map<Character,Integer> map1=new HashMap<>();
        Map<Character,Integer> map2=new HashMap<>();
        for (int i = 0; i < s1.length(); i++) {
            map1.put(s1.charAt(i),map1.getOrDefault(s1.charAt(i),0)+1);
            map2.put(s2.charAt(i),map2.getOrDefault(s2.charAt(i),0)+1);
        }
        return map1.equals(map2);
    }
}
